package cn.wolfcode.crm.service.impl;

import cn.wolfcode.crm.domain.BigClient;
import cn.wolfcode.crm.mapper.BigClientMapper;
import cn.wolfcode.crm.query.QueryForObject;
import cn.wolfcode.crm.service.IBigClientService;
import cn.wolfcode.crm.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BigClientServiceImpl implements IBigClientService {

    @Autowired
    private BigClientMapper bigClientMapper;

    public void deleteByPrimaryKey(Long id) {
        bigClientMapper.deleteByPrimaryKey(id);
    }

    public void insert(BigClient bigClient) {
        bigClientMapper.insert(bigClient);
    }

    public BigClient selectByPrimaryKey(Long id) {
        return bigClientMapper.selectByPrimaryKey(id);
    }

    public List<BigClient> selectAll() {
        return bigClientMapper.selectAll();
    }

    public void updateByPrimaryKey(BigClient bigClient) {
        bigClientMapper.updateByPrimaryKey(bigClient);
    }

    public PageResult queryListByQo(QueryForObject qo) {
        int total = bigClientMapper.getTotalByQo(qo);
        if (total == 0) {
            return new PageResult();
        }
        List<BigClient> rows = bigClientMapper.getListByQo(qo);
        return new PageResult(total, rows);
    }

    public void contract(Long id) {
        bigClientMapper.contract(id);
    }
}
